/*
 * Copyright (C) 2011 Dirk Weißenborn, dirk.weissenborn@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.weissenborn.colabtex.client.activities;

import com.weissenborn.colabtex.client.ClientFactory;
import com.weissenborn.colabtex.client.view.DashboardView;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

/**
 * The Class DashboardActivity which controls the view of the dashboard
 */
public class DashboardActivity extends AbstractActivity implements DashboardView.Presenter {
	
	/** The client factory. */
	private ClientFactory clientFactory;


	/**
	 * Instantiates a new dashboard activity.
	 *
	 * @param clientFactory the client factory
	 */
	public DashboardActivity(ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
	}

	/* (non-Javadoc)
	 * @see com.google.gwt.activity.shared.Activity#start(com.google.gwt.user.client.ui.AcceptsOneWidget, com.google.gwt.event.shared.EventBus)
	 */
	public void start(AcceptsOneWidget containerWidget, EventBus eventBus) {
		DashboardView view = clientFactory.getDashboardView();
		view.setPresenter(this);
		
		view.setText("Welcome to ColabTex, "+clientFactory.getUser().getId()+"!\n\n" +
					 "Please change your old username to a working email adress of yours in your account management to use mailing functions!\n" +
					 "Check your spam if you can't find emails!");
		containerWidget.setWidget(view.asWidget());
	}

	/* (non-Javadoc)
	 * @see com.weissenborn.colabtex.client.view.DashboardView.Presenter#goTo(com.google.gwt.place.shared.Place)
	 */
	public void goTo(Place place) {
		clientFactory.getPlaceController().goTo(place);
	}

}
